package com.framework.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.dao.DictDao;
import com.framework.entity.sys.SysDict;
import com.framework.exception.RRException;
import com.framework.exception.menu.RespCode;
import com.framework.service.DictService;
import com.framework.validator.Assert;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("dictService")
public class DictServiceImpl extends ServiceImpl<DictDao, SysDict> implements DictService {

	@Override
	public SysDict querySysDict(String code, String type) {
		Assert.isBlank(code, "code不能为空");
		Assert.isBlank(type, "type不能为空");
		SysDict s = new SysDict();
		s.setCode(code);
		s.setType(type);
		return baseMapper.selectOne(s);
	}

	@Override
	public List<SysDict> queryDictList(String code, String type) {
		if(StringUtils.isBlank(code) || StringUtils.isBlank(type)){
			throw new RRException(RespCode.NOT_PARAM_ERROR);
		}
		return baseMapper.queryDictList(code,type);
	}

	@Override
	public SysDict querySysDict(Integer orderNum, String code, String type) {
		Assert.isBlank(code, "code不能为空");
		Assert.isBlank(type, "type不能为空");
		if(orderNum==null){
			throw new RRException("9000","orderNum不能为空");
		}
		SysDict s=new SysDict();
		s.setCode(code);
		s.setOrderNum(orderNum);
		s.setType(type);
		return baseMapper.selectOne(s);
	}
}
